using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;

namespace TongJi_EMS._TJ_Basic
{
    [Designer(typeof(TongJi_EMS._TJ_Basic.TJ_BasicControlDesigner))]
    public class TJ_BasicControl : UserControl
    {
        public TJ_BasicControl()
        {
            TongJi_EMS._Event.TJ_Notice.Instance.EditableChanged += new TongJi_EMS._Event.TJ_Delegate.EditableChangedHandler(TJ_BControl_EditableChanged);
        }

        void TJ_BControl_EditableChanged(object sender, TongJi_EMS._Event.TJEventArgs e)
        {
            _editable = e.Editable;
        }

        #region Events
        public event _Event.TJ_Delegate.BolChangedHandler BolChanged;
        #endregion

        #region Properties
        private TJ_BasicControlDesigner _basicControlDesigner = null;

        public TJ_BasicControlDesigner BasicControlDesigner
        {
            get { return _basicControlDesigner; }
            set { _basicControlDesigner = value; }
        }

        private string _state = "0";
        public string State
        {
            get { return _state; }
            set
            {
                _state = value;
                BolChanged(new TongJi_EMS._Event.TJBolChangeArgs(_state));
            }
        }

        private Color _ctrColor = Color.Red;
        [CategoryAttribute("Data")]
        [Description("Color of current control")]
        public Color CtrColor
        {
            get { return _ctrColor; }
            set
            {
                _ctrColor = value;
                this.Refresh();
            }
        }

        private bool _editable = true;
        [CategoryAttribute("Data")]
        [Description("Indicating whether the control can currently be edited")]
        public bool Editable
        {
            get { return _editable; }
            set { _editable = value; }
        }

        private int _dbpointID = 0;
        [CategoryAttribute("Data")]
        [Description("Representing the Dbpoint that is associated with current control")]
        public int DbpointID
        {
            get { return _dbpointID; }
            set { _dbpointID = value; }
        }


        private int _dbareaID = 0;
        [CategoryAttribute("Data")]
        [Description("Representing the DbArea that is associated with current control")]
        public int DbAreaID
        {
            get { return _dbareaID; }
            set { _dbareaID = value; }
        }

        private bool _needPoint = false;
        [CategoryAttribute("Data")]
        [Description("Indicating whether current control need to attach to an existing dbpoint")]
        public bool NeedPoint
        {
            get { return _needPoint; }
            set { _needPoint = value; }
        }

        private bool _needColorChange = true;
        [CategoryAttribute("Data")]
        [Description("Indicating whether current control need to change color")]
        public bool NeedColorChange
        {
            get { return _needColorChange; }
            set { _needColorChange = value; }
        }
        #endregion
    }

    [Designer(typeof(TJ_BasicLabelDesigner))]
    [System.Drawing.ToolboxBitmap(typeof(Label))]
    public class TJ_BasicLabel : Label
    {
        public TJ_BasicLabel()
        {
            TongJi_EMS._Event.TJ_Notice.Instance.EditableChanged += new TongJi_EMS._Event.TJ_Delegate.EditableChangedHandler(TJ_BWControl_EditableChanged);
        }

        void TJ_BWControl_EditableChanged(object sender, TongJi_EMS._Event.TJEventArgs e)
        {
            _editable = e.Editable;
        }

        private TJ_BasicLabelDesigner _basicControlDesigner = null;

        public TJ_BasicLabelDesigner BasicControlDesigner
        {
            get { return _basicControlDesigner; }
            set { _basicControlDesigner = value; }
        }


        private bool _editable = true;
        [CategoryAttribute("Data")]
        [Description("Indicating whether the control can currently be edited")]
        public bool Editable
        {
            get { return _editable; }
            set { _editable = value; }
        }

        private bool _needPoint = false;
        [CategoryAttribute("Data")]
        [Description("Indicating whether current control need to attach to an existing dbpoint")]
        public bool NeedPoint
        {
            get { return _needPoint; }
            set { _needPoint = value; }
        }


    }

    [Designer(typeof(TJ_BasicButtonDesigner))]
    [System.Drawing.ToolboxBitmap(typeof(Button))]
    public class TJ_BasicButton : Button
    {
        public TJ_BasicButton()
        {
            TongJi_EMS._Event.TJ_Notice.Instance.EditableChanged += new TongJi_EMS._Event.TJ_Delegate.EditableChangedHandler(TJ_BWControl_EditableChanged);
        }

        void TJ_BWControl_EditableChanged(object sender, TongJi_EMS._Event.TJEventArgs e)
        {
            _editable = e.Editable;
        }

        private TJ_BasicButtonDesigner _basicControlDesigner = null;

        public TJ_BasicButtonDesigner BasicControlDesigner
        {
            get { return _basicControlDesigner; }
            set { _basicControlDesigner = value; }
        }


        private bool _editable = true;
        [CategoryAttribute("Data")]
        [Description("Indicating whether the control can currently be edited")]
        public bool Editable
        {
            get { return _editable; }
            set { _editable = value; }
        }

        private bool _needPoint = false;
        [CategoryAttribute("Data")]
        [Description("Indicating whether current control need to attach to an existing dbpoint")]
        public bool NeedPoint
        {
            get { return _needPoint; }
            set { _needPoint = value; }
        }

        private string _fileLink = "";
        [CategoryAttribute("Data")]
        [Description("Indicating the full path of the project file which is attached to current button")]
        public string FileLink
        {
            get { return _fileLink; }
            set { _fileLink = value; }
        }

        private string _subPageName = "";
        [CategoryAttribute("Data")]
        public string SubPageName
        {
            get { return _subPageName; }
            set { _subPageName = value; }
        }
    }

    [Designer(typeof(TJ_BasicTextBoxDesigner))]
    [System.Drawing.ToolboxBitmap(typeof(TextBox))]
    public class TJ_BasicTextBox : TextBox
    {
        public TJ_BasicTextBox()
        {
            TongJi_EMS._Event.TJ_Notice.Instance.EditableChanged += new TongJi_EMS._Event.TJ_Delegate.EditableChangedHandler(TJ_BWControl_EditableChanged);
        }

        void TJ_BWControl_EditableChanged(object sender, TongJi_EMS._Event.TJEventArgs e)
        {
            _editable = e.Editable;
        }

        private TJ_BasicTextBoxDesigner _basicControlDesigner = null;

        public TJ_BasicTextBoxDesigner BasicControlDesigner
        {
            get { return _basicControlDesigner; }
            set { _basicControlDesigner = value; }
        }


        private bool _editable = true;
        [CategoryAttribute("Data")]
        [Description("Indicating whether the control can currently be edited")]
        public bool Editable
        {
            get { return _editable; }
            set { _editable = value; }
        }
        private Color _ctrcolor = Color.Red;
        public Color CtrColor
        {
            get { return _ctrcolor; }
            set { _ctrcolor = value; }
        }

        private int _dbpointID = 0;
        [CategoryAttribute("Data")]
        [Description("Representing the Dbpoint that is associated with current control")]
        public int DbpointID
        {
            get { return _dbpointID; }
            set { _dbpointID = value; }
        }

        private int _dbareaID = 0;
        [CategoryAttribute("Data")]
        [Description("Representing the DbArea that is associated with current control")]
        public int DbAreaID
        {
            get { return _dbareaID; }
            set { _dbareaID = value; }
        }

        private bool _needPoint = false;
        [CategoryAttribute("Data")]
        [Description("Indicating whether current control need to attach to an existing dbpoint")]
        public bool NeedPoint
        {
            get { return _needPoint; }
            set { _needPoint = value; }
        }
    }

    [Designer(typeof(TJ_BasicComboBoxDesigner))]
    [System.Drawing.ToolboxBitmap(typeof(ComboBox))]
    public class TJ_BasicComboBox : ComboBox
    {
        public TJ_BasicComboBox()
        {
            TongJi_EMS._Event.TJ_Notice.Instance.EditableChanged += new TongJi_EMS._Event.TJ_Delegate.EditableChangedHandler(TJ_BWControl_EditableChanged);
        }

        void TJ_BWControl_EditableChanged(object sender, TongJi_EMS._Event.TJEventArgs e)
        {
            _editable = e.Editable;
        }

        private TJ_BasicComboBoxDesigner _basicControlDesigner = null;

        public TJ_BasicComboBoxDesigner BasicControlDesigner
        {
            get { return _basicControlDesigner; }
            set { _basicControlDesigner = value; }
        }

        private string _combinedLabel = "";
        [CategoryAttribute("Data")]
        [Description("The name of the Label which is combined to this ComboBox , and the Label is designed to display value of the selected ComboBoxItem")]
        public string CombinedLabel
        {
            get { return _combinedLabel; }
            set { _combinedLabel = value; }
        }

        private bool _editable = true;
        [CategoryAttribute("Data")]
        [Description("Indicating whether the control can currently be edited")]
        public bool Editable
        {
            get { return _editable; }
            set { _editable = value; }
        }

        private int[] _dbpointID;
        [CategoryAttribute("Data")]
        [Description("Representing the DbpointID that is associated with the Items of this ComboBox")]
        public int[] DbpointID
        {
            get { return _dbpointID; }
            set { _dbpointID = value; }
        }

        private int _combinedIndex = 0;
        public int CombinedIndex
        {
            get { return _combinedIndex; }
            set { _combinedIndex = value; }
        }
    }
}
